package com.ckr.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Shadowckr
 * @create 2022-01-01 11:33
 */

////实现该接口的类获得控制器功能
//public interface Controller {
//    //处理请求且返回一个模型与视图对象
//    ModelAndView handleRequest(HttpServletRequest var1, HttpServletResponse var2) throws Exception;
//}

//定义控制器
//注意点：不要导错包，实现Controller接口，重写方法
public class ControllerTest1 implements Controller {
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest,
                                      HttpServletResponse httpServletResponse) throws Exception {
        //返回一个模型视图对象
        ModelAndView mv = new ModelAndView();
        mv.addObject("msg", "Test1Controller");
        mv.setViewName("test");
        return mv;
    }
}
